class_name Reactor
extends Node

#region 属性
@export var react_node:Node
@export var trigger:Trigger
@export var fn_pool:GDScript
@export var fn_name:String = ""
@export var fn_args = {}
var connect_obj:ConnectObj
#endregion
#region 字段
#endregion
#region 信号
#endregion

#region 基类方法
#endregion
#region 公共方法
#endregion
#region 私有方法
#endregion
#region 生命周期函数
func _ready() -> void:
	if not trigger:
		trigger = get_parent()
	if not react_node:
		if not trigger.is_node_ready():
			await trigger.ready
		react_node = trigger.trigger_node
	if not fn_pool:
		fn_pool = FnPool
	if not fn_pool.has_method(fn_name):
		printerr("fn_name[{1}] not exist in fn[{2}]".format([fn_name,str(fn_pool)]))
		return
	connect_obj = ConnectObj.new(trigger.triggered,[func(data:Dictionary):
		Callable(fn_pool,fn_name).call(react_node,fn_args,data)]
		)
func _notification(what: int) -> void:
	if what == NOTIFICATION_PREDELETE:
		if connect_obj:
			connect_obj.disconnect_all()
#endregion
